package com.yojcodesendbox.codesendbox.factory;

import com.yojcodesendbox.codesendbox.CodeSandbox;
import com.yojcodesendbox.codesendbox.impl.CPlusPlusNativeCodeSendbox;
import com.yojcodesendbox.codesendbox.impl.JavaNativeCodeSendbox;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class ExecuteCodeSendBoxFactory {

    JavaNativeCodeSendbox javaNativeCodeSendbox;
    CPlusPlusNativeCodeSendbox cPlusPlusNativeCodeSendbox;

    @Autowired
    public void setJavaNativeCodeSendbox(JavaNativeCodeSendbox javaNativeCodeSendbox) {
        this.javaNativeCodeSendbox = javaNativeCodeSendbox;
    }

    @Autowired
    public void setcPlusPlusNativeCodeSendbox(CPlusPlusNativeCodeSendbox cPlusPlusNativeCodeSendbox) {
        this.cPlusPlusNativeCodeSendbox = cPlusPlusNativeCodeSendbox;
    }

    public CodeSandbox getCodeSandbox(String language) {
        switch (language) {
            case "java": return javaNativeCodeSendbox;
            case "c++": return cPlusPlusNativeCodeSendbox;
        }
        // 默认
        return new JavaNativeCodeSendbox();
    }
}
